<template>
  <div class="info-card">
    <el-row>
      <el-col :span="24">
        <div class="card">
          <img :src="coverImgUrl + '?param=200x200'" class="image" />
          <div class="name">{{ name }}</div>
          <div>
            <div class="bottom">
              <!-- 初始化状态是歌单信息展示卡片 -->
              <p v-if="introduce.updateTime" class="time">
                {{ getLocalTime(introduce.updateTime) }} 更新
              </p>
              <p v-if="introduce.playCount" class="count">
                播放:{{ introduce.playCount }}次
              </p>
              <!-- 有歌手是歌曲信息展示卡片 -->
              <p v-if="introduce.artist">by：{{ introduce.artist }}</p>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
  props: {
    coverImgUrl: String,
    name: String,
    introduce: Object
  },
  setup() {
    /* 简单的时间格式化 */
    const getLocalTime = (nS: string): string => {
      return new Date(parseInt(nS))
        .toLocaleString()
        .replace(/年|月/g, '-')
        .replace(/日/g, ' ')
    }

    return {
      getLocalTime
    }
  }
})
</script>

<style scoped lang="less">
.info-card {
  .card {
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 2px 2px 4px rgba(201, 114, 114, 0.432);
    .image {
      width: 80px;
      height: 80px;
      float: left;
      margin: 4px 0.2rem 4px 10px;
      border-radius: 40px;
      border: 2px solid #fff;
    }
    .name {
      height: 50px;
      margin-right: 0.1rem;
      line-height: 70px;
      font-size: 0.4rem;
      color: rgb(184, 0, 0);
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .bottom {
      display: flex;
      height: 30px;
      line-height: 50px;
      color: rgb(104, 104, 104);
      font-size: 0.1rem;
      font-style: italic;

      .time {
        flex: 1;
      }
      .count {
        flex: 1;
      }
    }
  }
}
</style>
